use std::cell::RefCell;
use std::rc::Rc;

pub struct TreeNode {
    pub val: i32,
    pub left: Option<Rc<RefCell<TreeNode>>>,
    pub right: Option<Rc<RefCell<TreeNode>>>,
}

pub fn inorder_traversal(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<i32> {
    fn inorder(node: Option<Rc<RefCell<TreeNode>>>, vec: &mut Vec<i32>) {
        if let Some(mut node) = node {
            inorder(node.borrow_mut().left.take(), vec);
            vec.push(node.borrow().val);
            inorder(node.borrow_mut().right.take(), vec);
        }
    }
    let mut ret = Vec::new();
    inorder(root, &mut ret);
    ret
}

#[test]
fn test_inorder_traversal() {

}
